//pthread_join 函数
#include <my_head.h>
void *task_func(void *arg){
    printf("我是子线程:[%ld] 10秒后退出\n", pthread_self());
    sleep(10);
    printf("我是子线程:[%ld] 退出\n", pthread_self());
    pthread_exit(NULL);
}
int main(int argc, const char *argv[]){
    pthread_t tid = 0;
    int ret = 0;
    if(0 != (ret = pthread_create(&tid, NULL, task_func, NULL))){
        printf("pthread_create error : [%d] [%s]\n", ret, strerror(ret));
        exit(EXIT_FAILURE);
    }
    printf("我是主线程:[%ld] 等待子线程结束 为其回收资源\n", pthread_self());
    if(0 != (ret = pthread_join(tid, NULL))){ //这是阻塞等待
        printf("pthread_join error : [%d] [%s]\n", ret, strerror(ret));
    }
    printf("我是主线程:[%ld] 给子线程回收资源成功\n", pthread_self());
    sleep(100);
    return 0;
}